/**
 * @MonsterConsole.as
 *
 * @author sodaChen mail:asframe@qq.com
 * @version 1.0
 * <br>Copyright (C), 2010-2015 asFrame.com
 * <br>This program is protected by copyright laws.
 * <br>Program Name:ASFrame Log
 * <br>Date:2016-4-28
 */
package com.asframe.log.console
{
	import com.asframe.log.ILogConsole;
	import com.asframe.log.Level;
	import com.demonsters.debugger.MonsterDebugger;

	/**
	 * 基于monsterdebugger的输出实现
	 * @author sodaChen
	 * Date:2016-4-28
	 */
	public class MonsterLogConsole implements ILogConsole
	{
		public var person:String = "ASFrame";

		public  function MonsterLogConsole(base:Object = null, address:String = "127.0.0.1")
		{
			if(base)
				initialize(base,address);
		}
		public function initialize(base:Object, address:String = "127.0.0.1"):void
		{
			MonsterDebugger.initialize(base,address);
		}
		public function console(level:Level, target:Object, logs:Array):void
		{
			//检测怪物编辑器是否有开启，有开启才打印信息
			if(!MonsterDebugger.connector.connected)
			{
				return ;
			}
			//根据等级来实现各种颜色和标签.深度还需要进
			if(logs.length == 1)
			{
				MonsterDebugger.trace(null,logs[0],person,level.name,level.color);
			}
			else
			{
				//如果还需要具体实现一些东西，则可以进行扩展或者重新实现该接口
				MonsterDebugger.trace(null,logs,person,level.name,level.color);
			}
		}
	}
}